﻿@using StackExchange.Opserver.Controllers
@model StackExchange.Opserver.Views.Exceptions.ExceptionsModel
@{
    var log = Model.SelectedLog;
    var exceptions = Model.Errors;

    this.SetPageTitle(Model.Title);
    this.SetTopSearch((log.HasValue() ? log + " " : "") + "Exceptions",
                      Model.Search,
                      Url.Action(nameof(ExceptionsController.Search)),
                      Model.SearchDictionary);
}
@section head {
    <script>
        $(function () { Status.Exceptions.init({ log: '@log', search: '@Model.Search', enablePreviews: @(Current.Settings.Exceptions.EnablePreviews ? "true" : "false"), showingDeleted: @(Model.ShowDeleted ? "true" : "false") }); });
    </script>
}
<h5 class="page-header">
    <a href="@Url.Action(nameof(ExceptionsController.Exceptions))">Exceptions</a>
    <span class="text-muted">/</span>
    @if (Model.SelectedGroup.HasValue())
    {
        <a href="@Url.Action(nameof(ExceptionsController.Exceptions), new { group = Model.SelectedGroup })">@Model.SelectedGroup</a>
        <span class="text-muted">/</span>
    }
    @if (Model.SelectedLog.HasValue())
    {
        <a href="@Url.Action(nameof(ExceptionsController.Exceptions), new { group = Model.SelectedGroup, log = Model.SelectedLog })">@Model.SelectedLog</a>
        <span class="text-muted">/</span>
    }
    Search
</h5>
<p class="small">
    @if (!Model.ShowDeleted)
    {
        @:Showing all current exception results, to include deleted exceptions <strong><a href="@Url.Action(nameof(ExceptionsController.Search), new { log, q = Model.Search, showDeleted = true })">click here</a></strong>.
    }
    else
    {
        @:Showing all exception results, including deleted.
    }
</p>
<div>
    @Html.Partial("Exceptions.Table", Model)
    <div class="no-content@(exceptions.Any() ? " hidden" : "")">
    @if (Model.ShowDeleted)
    {
        @:No current or deleted exceptions found
    } 
    else 
    {                
        @:No current exceptions found, <a href="@Url.Action(nameof(ExceptionsController.Search), new { log, q = Model.Search, showDeleted = true })">would you like to search deleted errors?</a>
    }
    </div>
</div>